package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TmStudentDeparture;
import com.ruoyi.system.service.ITmStudentDepartureService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生离校Controller
 * 
 * @author ruoyi
 * @date 2024-12-05
 */
@RestController
@RequestMapping("/system/departure")
public class TmStudentDepartureController extends BaseController
{
    @Autowired
    private ITmStudentDepartureService tmStudentDepartureService;

    /**
     * 查询学生离校列表
     */
    @PreAuthorize("@ss.hasPermi('system:departure:list')")
    @GetMapping("/list")
    public TableDataInfo list(TmStudentDeparture tmStudentDeparture)
    {
        startPage();
        List<TmStudentDeparture> list = tmStudentDepartureService.selectTmStudentDepartureList(tmStudentDeparture);
        return getDataTable(list);
    }

    /**
     * 导出学生离校列表
     */
    @PreAuthorize("@ss.hasPermi('system:departure:export')")
    @Log(title = "学生离校", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TmStudentDeparture tmStudentDeparture)
    {
        List<TmStudentDeparture> list = tmStudentDepartureService.selectTmStudentDepartureList(tmStudentDeparture);
        ExcelUtil<TmStudentDeparture> util = new ExcelUtil<TmStudentDeparture>(TmStudentDeparture.class);
        util.exportExcel(response, list, "学生离校数据");
    }

    /**
     * 获取学生离校详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:departure:query')")
    @GetMapping(value = "/{departureId}")
    public AjaxResult getInfo(@PathVariable("departureId") Long departureId)
    {
        return success(tmStudentDepartureService.selectTmStudentDepartureByDepartureId(departureId));
    }

    /**
     * 新增学生离校
     */
    @PreAuthorize("@ss.hasPermi('system:departure:add')")
    @Log(title = "学生离校", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TmStudentDeparture tmStudentDeparture)
    {
        return toAjax(tmStudentDepartureService.insertTmStudentDeparture(tmStudentDeparture));
    }

    /**
     * 修改学生离校
     */
    @PreAuthorize("@ss.hasPermi('system:departure:edit')")
    @Log(title = "学生离校", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TmStudentDeparture tmStudentDeparture)
    {
        return toAjax(tmStudentDepartureService.updateTmStudentDeparture(tmStudentDeparture));
    }

    /**
     * 删除学生离校
     */
    @PreAuthorize("@ss.hasPermi('system:departure:remove')")
    @Log(title = "学生离校", businessType = BusinessType.DELETE)
	@DeleteMapping("/{departureIds}")
    public AjaxResult remove(@PathVariable Long[] departureIds)
    {
        return toAjax(tmStudentDepartureService.deleteTmStudentDepartureByDepartureIds(departureIds));
    }
}
